package com.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

/**
 * 定时服务
 */

@Service
public class TimeTaskService {

    @Autowired
    private RedisTemplate  redisTemplate;

    /**
     * 每隔5秒检查删除过期的验证码
     */
    @Scheduled(cron = "0/5 * * * * ?")
    public void removeExpireCode()
    {
         redisTemplate.boundZSetOps("mail").removeRangeByScore(0,System.currentTimeMillis()-30*60*1000);
    }
}
